<template>
	<view>
		<PageHead backPath="/pages/user/index?p=3"></PageHead>
		<view class="margin-30 fs-white">
			<ul>
				<li v-for="item in requestList">
					<Acard bgFilter pad="12px">
						<view>
							<view class="mb-5">申请社团：{{ item.society_title }}</view>
							<view class="mb-5">申请于：{{ $u.timeFormat(item.apply_time, 'yyyy年mm月dd日') }}</view>
							<view class="mb-5">申请状态：{{ item.done == 0 ? '暂未通过' : item.done == 2? '被拒绝' :'被其他社团录取' }}</view>
							<view class="mb-5">申请理由：{{ item.content || '未填写' }}</view>
							<button size="mini" @click="undoRequest(item.id)">撤销申请</button>
						</view>
					</Acard>
				</li>
			</ul>
		</view>
		<ParticleBackground></ParticleBackground>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
		};
	},
	mounted() {
		this.getMyRequestList();
	},
	methods: {
		getMyRequestList() {
			this.$store.dispatch('society/getMyRequest', this.userinfo.id);
		},
		// 撤销申请
		async undoRequest(id){
			let {data} = await uni.$u.http.get('society/join/undo',{params:{id}})
			if(data.code === 200){
				uni.showToast({
					title:"撤销成功",
					icon:"success",
					success: () => {
						this.getMyRequestList()
					}
				})
			}
		},
	},
	computed: {
		...mapState('user', ['userinfo']),
		...mapState('society', ['requestList'])
	}
};
</script>

<style lang="scss"></style>
